package com.unionfind;

import lombok.Data;

/**
 * @Author: tgy
 * @Date: 2020-10-21 11:00
 */

public class Person {

    private String name;
    private Integer age;

    public Person(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {

            return true;
        }
        if (!(o instanceof Person)) {

            return false;
        }

        Person person = (Person) o;

        if (getName() != null ? !getName().equals(person.getName()) : person.getName() != null) {

            return false;
        }
        return getAge() != null ? getAge().equals(person.getAge()) : person.getAge() == null;
    }

    @Override
    public int hashCode() {

        int result = getName() != null ? getName().hashCode() : 0;
        result = 31 * result + (getAge() != null ? getAge().hashCode() : 0);
        return result;
    }
}
